<?php
/**
* Defines a user
*
*/
class User {
	private $userId;
	private $userName;
	private $firstName;
	private $lastName;
	private $email;
	private $roleId;
	private $roleName;
	private $deletable;
	private $modifiable;
	private $unitId;
	private $actions=array();
	private $valid=false;
	private $companyName;
	private $unitName;

	public function getUserId() {
		return $this->userId;
	}
	public function setUserId($userId) {
		$this->userId=$userId;
	}
	public function getUserName() {
		return $this->userName;
	}
	public function setUserName($userName) {
		$this->userName=$userName;
	}
	public function getFirstName() {
		return $this->firstName;
	}
	public function setFirstName($firstName) {
		$this->firstName=$firstName;
	}
	public function getLastName() {
		return $this->lastName;
	}
	public function setLastName($lastName) {
		$this->lastName=$lastName;
	}
	public function getEmail() {
		return $this->email;
	}
	public function setEmail($email) {
		$this->email=$email;
	}
	public function getRoleId() {
		return $this->roleId;
	}
	public function setRoleId($roleId) {
		$this->roleId=$roleId;
	}
	public function getRoleName() {
		return $this->roleName;
	}
	public function setRoleName($roleName) {
		$this->roleName=$roleName;
	}
	public function getDeletable() {
		return $this->deletable;
	}
	public function setDeletable($deletable) {
		$this->deletable=$deletable;
	}
	public function getModifiable() {
		return $this->modifiable;
	}
	public function setModifiable($modifiable) {
		$this->modifiable=$modifiable;
	}
	public function getUnitId() {
		return $this->unitId;
	}
	public function setUnitId($unitId) {
		$this->unitId=$unitId;
	}
	public function setValid($valid) {
		$this->valid=$valid;
	}
	public function isValid() {
		return $this->valid;
	}
	public function getCompanyName() {
		return $this->companyName;
	}
	public function setCompanyName($companyName) {
		$this->companyName=$companyName;
	}
	public function getUnitName() {
		return $this->unitName;
	}
	public function setUnitName($unitName) {
		$this->unitName=$unitName;
	}
	
	public function addAction($action,$level) {
		$levelaction=$this->actions[$level];
		array_push($levelaction , $action);
		$this->setActions($levelaction,$level);
	}
	public function getActions($level) {
		
		return $this->actions[$level];
	}
	public function setActions($actions,$level) {
		$this->actions[$level]=$actions;
	}
	public function isActionAllowed($action, $level){
		$tempActions=$this->getActions($level);
		$matched=false;
		foreach($tempActions as $tempAction){
			if($tempAction == $action){
				$matched=true;
			}
		}
		return $matched;
	}	
}
?>